/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session;

import entity.Menu;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author owtee
 */
@Stateless
public class MenuFacade extends AbstractFacade<Menu> {

    @PersistenceContext(unitName = "MSGPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public MenuFacade() {
        super(Menu.class);
    }

    public List<Menu> findByMenuRole(String menuRole) {
        em.getEntityManagerFactory().getCache().evictAll();
        return em.createQuery("SELECT m FROM Menu m WHERE m.menuPK.menuRole = :menuRole ORDER BY m.menuSeq")
                .setParameter("menuRole", menuRole)
                .getResultList();
    }
}
